[−][src]Crate viuer
Library to display images in the terminal.
This library contains functionality extracted from the viu
crate.
It aims to provide an easy to use interface to print images in the terminal. Uses some abstractions
provided by the image
crate. The Kitty graphics protocol
is partially supported. It is used by default. If the terminal doesn't support it, viuer
will fallback
to using regular half blocks instead (▄ and ▀).
Basic Usage
The example below shows how to print the image img.jpg
in 40x30 terminal cells, with vertical
offset of 4 and horizontal of 10, starting from the top left corner. More options are available
through the Config struct.
use viuer::{Config, print_from_file}; let conf = Config { width: Some(40), height: Some(30), x: 10, y: 4, ..Default::default() }; // will resize the image to fit in 40x30 terminal cells and print it print_from_file("img.jpg", &conf).expect("Image printing failed.");
Structs
Config | Configuration struct to customize printing behaviour. |
Enums
KittySupport | The extend to which the Kitty graphics protocol can be used. |
ViuError | Custom error type for |
Functions
has_kitty_support | Returns the terminal's support for the Kitty graphics protocol. |
Default printing method. Uses Kitty protocol, if supported, and half blocks otherwise. | |
print_from_file | Helper method that reads a file, tries to decode it and prints it. |
resize | Resize a image::DynamicImage so that it fits within optional width and height bounds. If none are provided, terminal size is used instead. |
terminal_size | Try to get the terminal size. If unsuccessful, fallback to a default (80x24). |